wayland: Clean up code to find the correct seat for a window
authorJasper St. Pierre <jstpierre@mecheye.net>
Thu, 15 May 2014 21:12:09 +0000 (17:12 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Thu, 15 May 2014 22:02:45 +0000 (18:02 -0400)
gdk/wayland/gdkwindow-wayland.c

index 87fa392a0598121a26f0149f2a8c30b1945f0833..aaab00aab8e7bf50386f6fa991a0b440f8ee7638 100644 (file)
@@ -990,6 +990,33 @@ gdk_wayland_window_create_xdg_popup (GdkWindow            *window,
   xdg_popup_add_listener (impl->xdg_popup, &xdg_popup_listener, window);
 }
 
+static struct wl_seat *
+find_grab_input_seat (GdkWindow *window, GdkWindow *transient_for)
+{
+  struct wl_seat *grab_input_seat = NULL;
+  GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+  GdkWindowImplWayland *tmp_impl;
+
+  /* Use the device that was used for the grab as the device for
+   * the popup window setup - so this relies on GTK+ taking the
+   * grab before showing the popup window.
+   */
+  grab_input_seat = impl->grab_input_seat;
+
+  tmp_impl = GDK_WINDOW_IMPL_WAYLAND (transient_for->impl);
+  while (!grab_input_seat)
+    {
+      grab_input_seat = tmp_impl->grab_input_seat;
+
+      if (tmp_impl->transient_for)
+        tmp_impl = GDK_WINDOW_IMPL_WAYLAND (tmp_impl->transient_for->impl);
+      else
+        break;
+    }
+
+  return grab_input_seat;
+}
+
 static void
 gdk_wayland_window_map (GdkWindow *window)
 {
@@ -1018,26 +1045,7 @@ gdk_wayland_window_map (GdkWindow *window)
 
       if (transient_for)
         {
-          struct wl_seat *grab_input_seat = NULL;
-          GdkWindowImplWayland *tmp_impl;
-
-          /* Use the device that was used for the grab as the device for
-           * the popup window setup - so this relies on GTK+ taking the
-           * grab before showing the popup window.
-           */
-          grab_input_seat = impl->grab_input_seat;
-
-          tmp_impl = GDK_WINDOW_IMPL_WAYLAND (transient_for->impl);
-          while (!grab_input_seat)
-            {
-              grab_input_seat = tmp_impl->grab_input_seat;
-
-              if (tmp_impl->transient_for)
-                tmp_impl = GDK_WINDOW_IMPL_WAYLAND (tmp_impl->transient_for->impl);
-              else
-                break;
-            }
-
+          struct wl_seat *grab_input_seat = find_grab_input_seat (window, transient_for);
           if (grab_input_seat &&
               (impl->hint == GDK_WINDOW_TYPE_HINT_POPUP_MENU ||
                impl->hint == GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU ||